// 认证事件系统
type AuthEventHandler = () => void;

class AuthEventManager {
  private listeners: AuthEventHandler[] = [];

  // 添加监听器
  addListener(handler: AuthEventHandler) {
    this.listeners.push(handler);
    return () => {
      this.listeners = this.listeners.filter(h => h !== handler);
    };
  }

  // 触发认证失效事件
  triggerAuthFailure() {
    this.listeners.forEach(handler => handler());
  }
}

export const authEventManager = new AuthEventManager(); 